package com.kede.api.auth.controller;

import com.kede.api.auth.domain.User;
import com.kede.api.auth.service.LoginService;
import com.kede.api.ienum.AppIdTypeEnum;
import com.kede.pojo.ResHttp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户相关
 */
@RestController
@RequestMapping("user")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 密码登录接口
     *
     * @Author: Pr.li
     * @Date: 2023/4/5 11:28
     * @Param: [com.kede.shangmenla.authserver.domain.User]
     * @Return: com.kede.shangmenla.pojo.ResHttp
     ***/
    @PostMapping("/login")
    public ResHttp login(@Validated @RequestBody User user){
        return loginService.login(user);
    }

    @PostMapping("/logout")
    public ResHttp logout(){
        return  loginService.logout();
    }


    @GetMapping("getWxPhone")
    public ResHttp getWxphone(String code, String appIdType){
        AppIdTypeEnum appIdTypeEnum = AppIdTypeEnum.valueOf(appIdType);
        String wxPhone = loginService.getWxPhone(code, appIdTypeEnum);
        return ResHttp.okData(wxPhone);
    }





}
